package cn.elves.model.draw.service.algorithm.guarantee.impl;

import cn.elves.model.draw.service.algorithm.DrawContextHolder;
import cn.elves.model.draw.service.algorithm.DrawParam;
import cn.elves.model.draw.service.algorithm.guarantee.GuaranteeDrawAlgorithm;

import java.util.HashMap;
import java.util.List;

/**
 * @author 精灵
 * @time 2024-06-19   11:25
 */
public class ProbabilisticGuaranteeFixedDrawAlgorithm extends GuaranteeDrawAlgorithm {

    @Override
    public String randomDraw(Long strategyId, List<String> excludeAwardIds) {
        DrawParam drawParam = DrawContextHolder.get();
        String userId = drawParam.getUserId();
        HashMap<String, Object> customDrawParam = drawParam.getCustomDrawParam();
        Integer times = (Integer)customDrawParam.get("unWinTimes");
        Integer guaranteeContants = (Integer)customDrawParam.get("guaranteeContants");
        if(guaranteeContants.equals(times)){
            String[] guaranteeAwardArr = guaranteeAwardMap.get(strategyId);
            int awardIdx = (int) (Math.random() * guaranteeAwardArr.length);
            return guaranteeAwardArr[awardIdx];
        }else{
            String[] awardArr = rateTupleMap.get(strategyId);
            int awardIdx = (int) (Math.random() * awardArr.length);
            return awardArr[awardIdx];
        }

    }
}
